/*
iiiiiiiiiiii iiiiiiiiiiii iiiiiiiiiiii ttttttttttt
i i i t
i i i t
i i i t
i i i t
i i i t
iiiiiiiiiiii iiiiiiiiiiii iiiiiiiiiiii t
*/
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int fcuk = 1000000;
bool sieve[1000001];
void createSieve()
{
sieve[1] = sieve[0] = false;
for(ll i=2;i<=fcuk;i++)
sieve[i] = true;
for(ll i=2;(i*i)<=fcuk;i++)
{
if(sieve[i] == true)
{
for(ll j=i*i;j<=fcuk;j+=i)
sieve[j] = false;
}
}
}
int gcd_equation(int a,int b,int& x,int& y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int x1,y1;
int d = gcd_equation(b,a%b,x1,y1);
x = y1;
y = x1 - (y1 * (a/b));
return d;
}
ll count_bits_kernighan_algo(ll n)
{
ll counter =0;
while(n!=0)
{
ll rsbm = n&(-n);
n -= rsbm;
counter++;
}
return counter;
}
void solve()
{
ll n,k; cin>>n>>k;
ll ans = INT_MAX;
for(ll i=1;i<k;i++)
{
if(n%i == 0)
ans = min(ans, n/i * k + i);
}
cout<<ans<<endl;
}
int main()
{
// ll t; cin>>t;
// while(t--)
solve();
}
802M - April Fools' Problem (easy) | 577B - Modulo Sum |
1555B - Two Tables | 1686A - Everything Everywhere All But One |
1469B - Red and Blue | 1257B - Magic Stick |
18C - Stripe | 1203B - Equal Rectangles |
1536A - Omkar and Bad Story | 1509A - Average Height |
1506C - Double-ended Strings | 340A - The Wall |
377A - Maze | 500A - New Year Transportation |
908D - New Year and Arbitrary Arrangement | 199A - Hexadecimal's theorem |
519C - A and B and Team Training | 631A - Interview |
961B - Lecture Sleep | 522A - Reposts |
1166D - Cute Sequences | 1176A - Divide it |
1527A - And Then There Were K | 1618E - Singers' Tour |
1560B - Who's Opposite | 182B - Vasya's Calendar |
934A - A Compatible Pair | 1618F - Reverse |
1684C - Column Swapping | 57C - Array |